import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/18 7:54
 * //两种排序方法
 * //求最小公倍数
 */
public class Day8 {
    public static void main1(String[] args) {
        //求最小公倍数
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        for (int i = Math.max(A,B); i <= A*B; i++) {
            if(i%A==0 && i% B == 0){
                System.out.println(i);
                break;
            }
        }
    }
    //两种排序方法
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
        int n = scanner.nextInt();
        String[] strArr = new String[n];
        for (int i = 0; i < n; i++) {
                strArr[i]=scanner.next();
        }
        //algo
        boolean lexicographically = true;
        boolean lengths = true;
        //lexicographically
        for (int i = 1; i < strArr.length; i++) {
            if(strArr[i].compareTo(strArr[i-1])<= 0){
                lexicographically = false;
                break;
            }
        }
        //lengths
        for (int i = 1; i < strArr.length; i++) {
            if(strArr[i].length() < strArr[i-1].length()){
                lengths=false;
                break;
            }
        }
        if (lexicographically && lengths){
            System.out.println("both");
        }else if(lengths){
            System.out.println("lengths");
        }else if(lexicographically){
            System.out.println("lexicographically");
        }else {
            System.out.println("none");
        }

    }
}
}

//Array 跳出 forEach 用break
//数组的长度不是可以任意改变的
//数组不属于原生类： 8个基本类型的包装类
//选择 10；
class Test{
    public static void main(String[] args) {
        System.out.println(new B().getValue());
    }

    static class A{
        protected int value;
        public A(int v){
            setValue(v);
        }

        public int getValue() {
            try {
                value++;
                return value;
            }catch (Exception e){
                System.out.println(e.toString());
            }finally {
                this.setValue(value);
                System.out.println(value);
            }
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }
    }
    static class B extends A{
        public B(){
            super(5);
            setValue(getValue()-3);
        }

        @Override
        public void setValue(int value) {
            super.setValue(2*value);
        }
    }
}
